// 已用全局组件 src/components/LimitInput 替换，后期确定不再需要可删除
import React from 'react';
import { Input } from 'antd';
import className from 'classnames';
import style from './index.less';

const { TextArea } = Input;

export default React.forwardRef(({ value, onChange, showWordLimit = false, maxLength, ...otherProps }, ref) => (
    <div
        className={className('vTextArea', style.vTextArea, { [style.vTextAreaDisabled]: otherProps.disabled })}
        ref={ref}
    >
        <TextArea value={value} onChange={onChange} {...otherProps} maxLength={maxLength} />
        {showWordLimit && maxLength ? (
            <div className={style.count}>
                {value ? value.length : 0}/{maxLength}
            </div>
        ) : null}
    </div>
));
